package com.sita.redsun.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by zhebinwang on 2017/3/29.
 */
public class AppContexConfig implements ApplicationContextAware {
    private static ApplicationContext appContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        appContext = applicationContext;
    }

    public static Object getBean(String beanId) throws BeansException {
        return appContext.getBean(beanId);
    }

    public static Object getBean(Class clazz) throws BeansException {
        return appContext.getBean(clazz);
    }
}
